package com.neutech.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.neutech.po.User;
import com.neutech.service.UserService;

@Controller
@RequestMapping(value="/user")
public class UserController {
	@Autowired
	private UserService userService;
	@RequestMapping("/findUser")
	public @ResponseBody User findUser(@RequestParam(value="id",required=true) Integer id){
		User user = userService.findUser(id);
		return user;
	}
	@RequestMapping(value="/updateUser",method=RequestMethod.POST)
	public @ResponseBody String updateUser(@RequestBody User user){
		userService.updateUser(user);
		return "修改成功";
	}
	@RequestMapping(value="/addUser",method=RequestMethod.POST)
	public @ResponseBody String addUser(@RequestBody User user){
		userService.addUser(user);
		return "增加成功";
	}
	@RequestMapping("/delUser")
	public @ResponseBody String delUser(@RequestParam(value="username",required=true) String username){
		userService.delUser(username);
		return "删除成功";
	}

}
